package com.linkhub.oms.admin.modules.pickuporder.domain.param;

import cn.hutool.core.lang.Validator;
import com.linkhub.oms.admin.modules.user.domain.param.BaseUserParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * @Description: PickUpOrderSaveOrUpdateParam
 * @Author: echo
 * @Date: 2024/5/2 09:42
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PickUpOrderSaveOrUpdateParam", description = "提货申请单参数对象")
public class PickUpOrderSaveOrUpdateParam extends BaseUserParam implements Serializable {

    @ApiModelProperty(value = "提货费，员工侧才有数据")
    private String takeDeliveryCost;

    @ApiModelProperty(value = "实际提货费，员工侧才有数据")
    private String realTakeDeliveryCost;

    @ApiModelProperty(value = "系统供应商id")
    @NotBlank(message = "{validation.supplier.sysSupplierId.notBlank}")
    private String sysSupplierId;

    @ApiModelProperty(value = "商品信息")
    @NotEmpty(message = "{validation.pickup.orderLineParams.notEmpty}")
    private List<EntryOrderLineParam> orderLines;

    @ApiModelProperty(value = "提货方式：1-供应商自送；2-shipO提货")
    @NotNull(message = "{validation.pick.up.deliveryMethod.notNull}")
    @Range(min = 1, max = 2, message = "{validation.pick.up.deliveryMethod.range}")
    private Integer deliveryMethod;

    /**
     * @see Validator#isMatchRegex(String, CharSequence)
     */
    @ApiModelProperty(value = "预计提货时间")
    private String predictDeliveryTime;

    @ApiModelProperty(value = "预计到货日期")
    // @NotNull(message = "{validation.pick.up.predictArrivalTime.notNull}")
    private String predictArrivalTime;

    @ApiModelProperty(value = "物流公司")
    private String logisticsCompany;

    @ApiModelProperty(value = "物流单号")
    private String logisticsOddNumber;

    @ApiModelProperty(value = "文件名称")
    private String attachmentName;

    @ApiModelProperty(value = "文件url")
    private String attachmentUrl;

    @ApiModelProperty(value = "司机名字")
    private String driverName;

    @ApiModelProperty(value = "司机电话")
    private String driverPhone;

    @ApiModelProperty(value = "车牌")
    private String licensePlate;

    @ApiModelProperty(value = "车型号")
    private String typeOfCar;




    /** ******* 以下非前端传值 *********/
    @ApiModelProperty(hidden = true)
    private String sysEntryOrderCode;

    @ApiModelProperty(value = "是否客户角色", hidden = true)
    private boolean customerRole;

    public void resetField() {
        if (customerRole) {
            this.setRealTakeDeliveryCost(null);
            this.setTakeDeliveryCost(null);
        }

        if (StringUtils.isBlank(this.getAttachmentUrl())) {
            this.setAttachmentUrl("");
        }

        if (StringUtils.isBlank(this.getAttachmentName())) {
            this.setAttachmentName("");
        }
    }


}
